﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BusinessLogic.Repository_Logic.Concentrate;
using BusinessLogic.Repository_Logic.Interfaces;
using Ninject;
using System.Web.Mvc;
using TestSystem.Domain.Abstract;
using TestSystem.Domain.Repositories;

namespace TestSystem.Infrastucture
{
    public class NinjectControllerFactory : DefaultControllerFactory
    {
        private IKernel ninjectKernel;

        public NinjectControllerFactory()
        {
            ninjectKernel = new StandardKernel();
            AddBindings();
        }
        protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            return controllerType == null ? null : (IController) ninjectKernel.Get(controllerType);
        }
        void AddBindings()
        {
            ninjectKernel.Bind<ICategoryRepository>().To<CategoriesRepository>();
            ninjectKernel.Bind<IQuestionRepositoryLogic>().To<QuestionRepositoryLogic>();
            ninjectKernel.Bind<IPositionRepositoryLogic>().To<PositionRepositoryLogic>();
            ninjectKernel.Bind<IAccountRepositoryLogic>().To<AccountRepositoryLogic>();
            ninjectKernel.Bind<ICandidateRepositoryLogic>().To<CandidateRepositoryLogic>();
        }
    }
}